package com.lishanyang.spring.aop;

import org.apache.log4j.Logger;
import org.springframework.aop.AfterReturningAdvice;

import java.lang.reflect.Method;


public class AfterLogAdvice implements AfterReturningAdvice {
    private Logger logger=Logger.getLogger(AfterLogAdvice.class);
    @Override
    public void afterReturning(Object o, Method method, Object[] objects, Object o1) throws Throwable {
        //获取被调用的类名
        String targetClassName=o1.getClass().getName();
        //获取被调用的方法名
        String targetMethodName=method.getName();
        //日志格式字符串
        String logInfoText="后置通知"+targetClassName+"类的"+targetMethodName+"方法已经执行";
        logger.info(logInfoText);
    }
}
